
# app = QApplication(sys.argv)

# svg_path = Path(__file__).resolve().parent / "aa.svg"
# if not svg_path.exists():
#     print("❌ 文件不存在：", svg_path)
#     sys.exit(1)

# window = QWidget()
# layout = QVBoxLayout()

# view = QWebEngineView()
# url = QUrl.fromLocalFile(str(svg_path.absolute()))
# print("加载 URL：", url.toString())
# view.load(url)

# view.loadFinished.connect(lambda ok: print("加载成功" if ok else "加载失败"))

# layout.addWidget(view)
# window.setLayout(layout)
# window.resize(800, 400)
# window.show()

# sys.exit(app.exec())

# main.py
import sys, pathlib
import os
os.chdir(os.path.dirname(__file__))
sys.path.insert(0, str(pathlib.Path(__file__).with_name('ui')))

from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtWebEngineWidgets import QWebEngineView
from PySide6.QtCore import QUrl
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout
from pathlib import Path
from ui_hvg import Ui_MainWindow   # 刚生成的类
import socket
SERVER_IP = "192.168.10.100"   # 目标地址
SERVER_PORT = 1111        # 目标端口
import struct
# 自定义格式：> 表示大端，B=uint8, H=uint16, I=uint32, 16s=16字节字符串
FORMAT = '>II II BB B I '


class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        ############################################################
        # ↓↓↓ 在这里写你的信号连接 ↓↓↓
        self.btnConnect.clicked.connect(self.on_connect)
        self.btnStart1.clicked.connect(self.on_btn_start1)
        ############################################################
        svg_path = Path(__file__).resolve().parent / "aa.svg"
        window = QWidget()
        layout = QVBoxLayout()


        url = QUrl.fromLocalFile(str(svg_path.absolute()))
        print("加载 URL：", url.toString())
        self.webEngineView.load(url)
        ############################################################
    def on_connect(self):
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    def on_btn_start1(self) :
        print("666")
if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = MainWindow()
    w.show()
    sys.exit(app.exec())